package com.product.system.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.product.system.domain.request.ArgpMachiningSerch;
import com.product.system.domain.response.ArgpMachining;
import com.product.system.domain.response.ArgpTradesmanCity;
import com.product.system.mapper.ArgpMachiningMapper;
import com.product.system.service.ArgpMachiningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArgpMachiningServiceImpl implements ArgpMachiningService {


    @Autowired
    ArgpMachiningMapper argpMachiningMapper;


    @Override
    public PageInfo<ArgpMachining> machiningList(ArgpMachiningSerch argpMachiningSerch) {
        PageHelper.startPage(argpMachiningSerch.getPageNum(),argpMachiningSerch.getPageSize());
        List<ArgpMachining> argpMachinings = argpMachiningMapper.machiningList(argpMachiningSerch);
        PageInfo<ArgpMachining> argpMachiningPageInfo = new PageInfo<>(argpMachinings);
        return argpMachiningPageInfo;
    }

    @Override
    public int machiningAdd(ArgpMachining argpMachining) {
        int i = 0;
        if (argpMachining.getMachiningId()!=null) {
          i =   argpMachiningMapper.machiningUpdata(argpMachining);
        }
         i = argpMachiningMapper.machiningAdd(argpMachining);
        return i;
    }

    @Override
    public int machiningDel(Integer id) {
        return argpMachiningMapper.machiningDel(id);
    }

    @Override
    public List<ArgpTradesmanCity> getOptionTreeList() {
        return argpMachiningMapper.getOptionTreeList();
    }

    @Override
    public List<ArgpMachining> machiningExcelList() {
        return argpMachiningMapper.machiningExcelList();
    }

    @Override
    public void loadinRoleMatchAdd(List<ArgpMachining> cachedArgpMachiningList) {
        argpMachiningMapper.machiningMatchAdd(cachedArgpMachiningList);
    }
}
